#include <bits/stdc++.h>

using namespace std;

int node[105];

int main(){
    int n, m;
    cin >> n >> m;
    
    node[0] = 0;
    for (int i = 1; i <= n; i++){
        node[i] = i + 1;
    }
    node[n] = 1;

    int prev = n, now = 1;
    while ((n--) > 1){
        for (int i = 1; i < m; i++){
            prev = now;
            now = node[now];
        }
        cout << now << " ";
        node[prev] = node[now];
        now = node[prev];
    }
    cout << now;

    return 0;
}